#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
#include <limits>
#include <string>

class Point 
{
public:
	double x, y;

	Point(double x_, double y_)
	{
		x = x_;
		y = y_;
	}

	double sqr_dist(const Point &p) 
	{
		return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y);
	}

	int solve(const std::vector<Point> points)
	{
		int ans = 0;
		double dist = sqr_dist(points[0]);

		for (size_t i = 1; i < points.size(); i++) 
		{
			if (sqr_dist(points[i]) <= dist) 
			{
				dist = sqr_dist(points[i]);
				ans = i;
			}
		}

		return ans;
	}
};

std::ostream& operator<<(std::ostream &os, const Point &p)
{
	os << p.x << " " << p.y << "\n";
	return os;
}

int main() 
{
	using std::cin;
	using std::cout;

	int n;
	cin >> n;

	std::vector<Point> points;
	double x, y;
	for (int i = 0; i < n; i++) 
	{
		cin >> x >> y;
		points.push_back(Point(x, y));
	}

	int m;
	cin >> m;

	cout.precision(100);
	for (int i = 0; i < m; i++) 
	{
		cin >> x >> y;
		cout << points[Point(x, y).solve(points)];
	}
}